export function largestNumber(nums: number[]): string {
    nums.sort((x, y) => {
        const num1 = y * getS(x) + x;
        const num2 = x * getS(y) + y;
        return num1 - num2;
    });
    
    // 排除 `000` 的情况
    const result = nums.join('');
    if (result.startsWith('0')) return '0'
    return result;
};

function getS (x: number) {
    let s = 10;
    while (s <= x) {
        s = s * 10;
    }

    return s;
}